home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / gnulib / sipp / srgp / src / grx / image.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-10  |  845 b   |  40 lines

  1. #include "srgplocal.h"
  2.  
  3. void SRGP_putImage(top_x, top_y, width, height, data)
  4.   int top_x, top_y, width, height;
  5.   char *data;
  6. {
  7.   GrContext GC;
  8.  
  9.   (void) GrCreateContext(width, height, data, &GC);
  10.   GrBitBlt((GrContext *) 0, top_x, top_y, &GC, 0, 0,
  11.            width, height, GrWRITE);
  12.   GrDestroyContext(&GC);
  13. }
  14.  
  15. int SRGP_loadGreyColorTable(first, last)
  16.   int first, last;
  17. {
  18.   static int first_time = 1;
  19.   int i, value;
  20.  
  21.   if (first == 0 && last == 0)
  22.     return 1;
  23.  
  24.   if (first < 16 || first >= last || last > 255)
  25.     return 0;
  26.  
  27.   if (first_time)
  28.   {
  29.     first_time = 0;
  30.     if (GrNumColors() != 256)
  31.       return 0;
  32.     for (i = first; i <= last; i++)
  33.     {
  34.       value = (int) ((float) (i - first) / (float) (last - first) * 255.99);
  35.       GrSetColor(i, value, value, value);
  36.     }
  37.   }
  38.   return 1;
  39. }
  40.